package work20241203_chap6oop.l_demo9_new;


/**
 * @author zdl
 * @date 2024/12/5
 */
public class Team {
    private Role1[] roles;
    private int count;

    public Team() {
        count = 0;
        roles = new Role1[6];
    }


    public Role1[] getRole1s() {
        return roles;
    }

    public void setRole1s(Role1[] roles) {
        this.roles = roles;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void addMember(Role1 role){
        if (count < 6){
            roles[count] = role;
            count++;
        }else {
            System.out.println("队伍已满");
        }
    }

    public int attackSum(Role1[] r){
        int num = 0;
        for (int i = 0; i < r.length; i++) {
            num += r[i].attack();
        }
        return num;
    }

}
